﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using DevExpress.XtraEditors.Repository;

namespace Warehouse_Management.UserControl
{
    public partial class KhoUC : DevExpress.XtraEditors.XtraUserControl
    {
        public KhoUC()
        {
            InitializeComponent();
        }
        public string MaKho 
        {
            get { return gluTenKho.EditValue.ToString().Trim(); }
            set { this.gluTenKho.EditValue = value; }
        }

        private IList<KhoHang> DMKho;
        private void KhoUC_Load(object sender, EventArgs e)
        {
            DMKho = KhoHang.SelectCollectionAll();
            gluTenKho.Properties.DataSource = DMKho;
            gluTenKho.Properties.ValueMember = "MaKho";
            gluTenKho.Properties.DisplayMember = "TenKho";
            gluTenKho.ItemIndex = 0;
            
        }

        private void gluTenKho_EditValueChanged(object sender, EventArgs e)
        {
            KhoHang kho = (KhoHang)gluTenKho.GetSelectedDataRow();
            txtMaKho.Text = kho.MaKho;
        }

        private void txtMaKho_EditValueChanged(object sender, EventArgs e)
        {
            gluTenKho.EditValue = txtMaKho.Text.Trim();
        }
    }
}
